﻿
    using Chain.BLL;
    using System;
    using System.Data;
    using System.Text;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public partial class StaffList : PageBase
    {


        private string BindStaff(string strCallbackFun)
        {
            StringBuilder sbHtml = new StringBuilder();
            DataTable dtStaffClass = new StaffClass().GetList(" SysShop.ShopID=StaffClass.ClassShopID ").Tables[0];
            sbHtml.Append("<ul class=\"mktree\" id=\"treeStaff\">");
            sbHtml.Append("<li><a href=\"javascript:void(0);\" onclick=\"javascript:" + strCallbackFun + "();\" style='font-size:14px;color:#303030;font-weight:bolder;'><img src='/images/ico/open.png'/>&nbsp;所有店铺</a></li>");
            if (base._UserShopID == 1)
            {
                sbHtml.Append("<ul>");
                DataTable dtShop = new SysShop().GetList("ShopID>0").Tables[0];
                foreach (DataRow dr in dtShop.Rows)
                {
                    sbHtml.Append(string.Concat(new object[] { "<li><font style='font-size:14px;color:#4f4e4e;'>&nbsp;&nbsp;&nbsp;&nbsp;<a href='#' class='mytrees' onclick='bindtree(", dr["ShopID"].ToString(), ")'><img id='img", dr["ShopID"].ToString(), "' src='/images/ico/close.png'/></a></font><a style='font-size:14px;color:#4f4e4e;' href=\"javascript:void(0);\" onclick=\"javascript:", strCallbackFun, "(", dr["ShopID"], ",true);\">&nbsp;店铺：", dr["ShopName"], "</a>" }));
                    CreateStaffClass(sbHtml, dtStaffClass, strCallbackFun, int.Parse(dr["ShopID"].ToString()));
                }
                sbHtml.Append("</ul>");
            }
            else
            {
                CreateStaffClass(sbHtml, dtStaffClass, strCallbackFun, base._UserShopID);
            }
            return sbHtml.ToString();
        }

        private static void CreateStaffClass(StringBuilder sbHtml, DataTable dtStaffClass, string strCallbackFun, int intShopID)
        {
            foreach (DataRow dr in dtStaffClass.Select("ClassShopID=" + intShopID))
            {
                sbHtml.Append(string.Concat(new object[] { "<ul class='selected", intShopID.ToString(), "' style='display:none;'><li style='padding-left:70px;'><img src='/images/ico/dot.gif'/>&nbsp;<a class='mytrees' style='font-size:12px;color:#4f4e4e;' href=\"javascript:void(0);\" onclick=\"javascript:", strCallbackFun, "(", dr["ClassID"], ",false);\">", dr["ClassName"], "</a>" }));
                sbHtml.Append("</li></ul>");
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                string strTree = this.BindStaff("StaffListTree");
                this.StaffList_ClassTree.InnerHtml = strTree;
                PubFunction.BindStaffClass(base._UserShopID, this.sltStaffClass, true);
            }
        }
    }


